package com.example.fete.Adapter;

import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;

import java.util.ArrayList;
import java.util.List;

public class GuideAdapter extends PagerAdapter {

    private List<View> mlist;

    public GuideAdapter(List<View> mlist) {
        this.mlist = mlist;
    }

    @Override
    public int getCount() {
        return mlist.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view == object;
    }

    /**
     *@ClassName:ViewPageAdapter - 销毁View的过程
     *@author:CaoJiaHao
     *@Param:
     **/
    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        container.removeView(mlist.get(position));
    }

    /**
     *@ClassName:ViewPageAdapter - 这个为显示的View
     *@author:CaoJiaHao
     *@Param:
     **/
    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, int position) {
        container.addView(mlist.get(position));
        return mlist.get(position);
    }
}
